// for detail def tutorial: http://www.scala-sbt.org/0.13/tutorial/Basic-Def.html
lazy val sbtTutorial = (project in file(".")).
  settings(commonSettings: _*).
  settings(
    /** will not compile if name := 42 */
    name := "sbtTutorial",

    /** referring to scopes in build definition */
    // Java style name.in(Compile).:=("hello")
    //    name in Compile := "sbtTutorialCompile",

    /** setting description value the same as project name */
    description := name.value,

    /** set the project name to the name of the project's directory */
    // name is a Key[String], baseDirectory is a Key[File]
    // name the project after the directory it's inside
    name := baseDirectory.value.getName,

    //    version := "1.0",
    //    scalaVersion := "2.11.5"

    /** task */
    helloTask := {
      println("Hello!")
    }
  )

/** move common setting to the parent build.sbt file <-- doesn't work, because sbt files doesn't share settings or values */
lazy val commonSettings = Seq(
  organization := "com.mikelouis.test.scala.sbt.tutorial",
  version := "0.0.1",
  scalaVersion := "2.12.0"
)

/** can invoke the task by running helloTask */
//> project sbtTutorial
//  [info] Set current project to sbtTutorial (in build file:/C:/Users/yuazhu/workspace_intellij/first-scala/)
//> helloTask
//  Hello!
//[success] Total time: 0 s, completed Mar 30, 2015 10:35:16 AM
lazy val helloTask = taskKey[Unit]("An example task")

lazy val sbtTutorialUtil = project in file("util")

lazy val sbtTutorialLib = project in file("lib")

// classpath dependency
lazy val sbtTutorialCore = project.in(file("core")).dependsOn(sbtTutorialUtil, sbtTutorialLib)

// project aggregation
lazy val buildDef = project.aggregate(sbtTutorialLib)